package com.base.day8;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class UserService {
	JDBCComon jdbc=new JDBCComon();
	//登录
	public boolean login(String name,String pwd){
		boolean rs=false;
		try {
			Connection conn=jdbc.getConnection();
			Statement st=conn.createStatement(); 
			String sql="select * from user where  name='"+name+"' and pwd='"+pwd+"'";
			System.out.println("sql--->"+sql);
			ResultSet rss=st.executeQuery(sql);
			//rss.next()只要 结果集合里，至少有一条记录，next方法就会返回true
			if(rss.next()){
				rs=true;
			}
			//从下往上关
			rss.close();
			st.close();
			conn.close();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return rs;
	}

}
